package cn.ac.jaas.ljx.wordsegmentation.util;

import java.util.List;

import cn.ac.jaas.ljx.wordsegmentation.domain.Word;

public class WordCountUtil {

	public static List<Word> wordCount(List<Word> wordsNoCount, List<Word> wordsCounted) {
		for(Word wordNoCount : wordsNoCount) {
			if(wordsCounted.contains(wordNoCount)) {
				for(Word wordCounted : wordsCounted) {
					if(wordNoCount.equals(wordCounted)) {
						wordCounted.setTime(wordCounted.getTime() + wordNoCount.getTime());
						break;
					}
				}
			} else {
				wordsCounted.add(wordNoCount);
			}
		}
		return wordsCounted;
	}
}
